package base.new18;

import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;
import java.util.stream.IntStream;
import java.util.stream.Stream;

/**
 * \* User: Administrator
 * <p>
 * \* Date: 2020/10/15
 * <p>
 * \* Time: 10:13
 * <p>
 * \* Description:
 * 1、流的创建
 * 2、流的中间操作
 * filter:用于通过设置的条件过滤出元素
 * map:用于映射每个元素到对应的结果
 * limit:返回 Stream 的前面 n 个元素；skip 则是扔掉前 n 个元素
 * sorted:
 * distinct:
 * 3、流的最终操作
 * \
 */
public class StreamMain {
    public static void main(String[] args) {
        List<String> list = Arrays.asList(new String[]{"1", "", "2", "3", "4", "5", "6"});
        Stream<String> stream = list.stream();
        Stream<String> stream1 = list.parallelStream();
        //filter过滤空字符串
        //stream.filter(String -> !String.isEmpty()).forEach(System.out::println);

        //map
        List<String> toList = stream.limit(4).sorted().collect(Collectors.toList());
        System.out.println(toList);
    }
}
